#!/bin/bash

dir=$(cd $(dirname $0); pwd)

script=$dir'/shortlink.py'

if [[ ! -e $script ]]
then
    echo '服务器程序不存在：'$script
    exit 1
fi

cat > /usr/lib/systemd/system/shortlink.service << EOF
[Unit]
Description=ShortLink Service
After=network.target

[Service]
Type=simple
ExecStart=python3 $script

[Install]
WantedBy=default.target

EOF

systemctl daemon-reload

systemctl enable shortlink

systemctl start shortlink

echo 'Installation Complete!'
